package com.fengye.serialization.serializer;

import com.fengye.serialization.engine.SerializerEngine;
import com.fengye.serialization.serializer.impl.DefaultJavaSerializer;

import java.util.*;

/**
 * @Author fengye
 * @Date 2023/2/12 16:38
 **/
public class SerializerMain {
    public static void main(String[] args) throws Exception {
        SerializerEngine engine = new SerializerEngine();
//        Serializer serializer = new DefaultJavaSerializer();

        List<String> lists = new ArrayList<String>();
        lists.add("123");
        lists.add("a");
        lists.add("b");

        Map<String, Integer> map = new HashMap<String, Integer>(8);
        map.put("a", 1);
        map.put("b", 2);
        map.put("c", 3);

        Date date = new Date();

        TestBean testBean = new TestBean("test", 123, lists, map, date);
        // HessianSerializer
        //DefaultJavaSerializer
        String serializerType = "MarshallingSerializer";

        byte[] bytes = SerializerEngine.serialize(testBean, serializerType);

        TestBean testBean1 = SerializerEngine.deserialize(bytes, TestBean.class, serializerType);

        System.out.println(testBean1);

    }
}
